SPB Git

Repository Public

page.tsx 3.4 KB 74 lines tsx

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : Music SP8 * File             : src/app/(app)/artiste/[id]/page.tsx9 * Module           : app10 * Repository       : https://git.spboucher.ai/sp-music11 * Project Website  : https://music.spboucher.ai12 * Created          : 2026-11-1713 * Last Modified    : 2026-11-1714 *15 * Author           : Simon-Pierre Boucher16 * Position         : Professor of Finance17 * Institution      : Université du Québec en Outaouais (UQO)18 * Organization     : SP Boucher19 * Website          : https://spboucher.ai20 * Git              : https://git.spboucher.ai21 *22 * Preferred Contact: support@spboucher.ai23 * Development      : dev@spboucher.ai24 * Support          : support@spboucher.ai25 * Security/Admin   : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License          : None specified (no license file in this repository)34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243"use client";44import { useParams } from "next/navigation";45import { useEffect } from "react";46import type { Album, Artist, Track } from "@/lib/types";47import { useT } from "@/i18n";48import { AlbumCard, Artwork, Async, Grid, PlayButtons, Section, TrackList, useApi } from "@/components/ui";4950export default function ArtistPage() {51  const { id } = useParams<{ id: string }>();52  const t = useT();53  const res = useApi<{ artist: Artist; albums: Album[]; tracks: Track[] }>(`/api/v1/library/artists/${id}`);54  const name = res.data?.artist.name;55  useEffect(() => { if (name) document.title = `${name} · Music SP`; }, [name]);56  return (57    <Async res={res}>{({ artist, albums, tracks }) => (58      <article>59        <header className="mb-8 flex flex-col items-center gap-5 text-center sm:flex-row sm:items-end sm:text-left">60          <Artwork artworkId={artist.artworkId} seed={artist.name} size={640} className="w-44 flex-none shadow-2xl shadow-black/60" rounded="rounded-full" priority />61          <div className="min-w-0 flex-1">62            <p className="text-xs font-bold uppercase tracking-widest text-faint">{t("artist.label")}</p>63            <h1 className="h-page mt-1 break-words">{artist.name}</h1>64            <p className="mt-1 text-sm text-muted">{t(albums.length === 1 ? "count.album" : "count.albums", { n: albums.length })} · {t(tracks.length === 1 ? "count.track" : "count.tracks", { n: tracks.length })}</p>65            <PlayButtons tracks={tracks} className="mt-4 justify-center sm:justify-start" />66          </div>67        </header>68        {albums.length > 0 && <Section title={t("lib.albums")}><Grid>{albums.map((a) => <AlbumCard key={a.id} album={a} />)}</Grid></Section>}69        {tracks.length > 0 && <Section title={t("lib.tracks")}><TrackList tracks={tracks} /></Section>}70      </article>71    )}</Async>72  );73}74
Files main
Menu

Theme